package com.twu.biblioteca.commands;

import com.twu.biblioteca.domain.Book;

import java.util.List;

public class AllActions {
    public String listBooks(List<Book> books) {
        String message = "";
        for (Book book : books) {
            message += book.getId();
            message += "\t";
            message += book.getName();
            message += "\n";
        }

        return message;
    }

    public String checkMembership(List<Book> books) {
        return "Please talk to a libryrian.Thank you!";
    }

    public String reserveBook(List<Book> books, String bookId) {
    for (Book book : books) {
            if (book.getId().equals(bookId)) {
                if (book.getIsBooked()) {
                    return "The book has been booked already.";
                } else {
                    book.setIsBooked(true);
                    return "Book succeed.Enjoy the book!";
                }
            }
        }
        return "The book is not exist!";
    }
    }

